package org.example.multiThreading.ThreadMethod;

public class MyThreadYield {
    public static void main(String[] args) {
        TestThread thread = new TestThread();
        TestThread thread1 = new TestThread();
        thread.start();
        thread1.start();
    }
}

class TestThread extends Thread{
    @Override
    public void run(){
        for (int i = 0; i < 10; i++) {
            System.out.println(Thread.currentThread().getName()+"-"+i);
            //主动放弃事件片，转为就绪状态
            Thread.yield();
        }
    }
}
